<template>
<view>
	<cu-custom :isBack="true" bgColor="bg-blue">
		<block slot="content">质量统计</block>
		<template slot="backText">
			<text class="cuIcon-back" @tap="beforePage"></text>
		</template>
	</cu-custom>
	<view style="height: 138upx;" class="padding-tb-20 padding-lr-30">
		<view class="search-fixed bg-blue" :style="{marginTop: CustomBar + 'px'}">
			<!-- 时间选择器 -->
			<view class="flex align-center date-select u-font-weight6 bg-blue">
				<picker mode="date" :value="date" start="1970-01-01" @change="DateChange">
					<view class="picker">
						{{date}}
					</view>
				</picker>
				<text class="ph-sousuoshijian position-text text-blue"></text>
			</view>
		</view>
	</view>
	<!-- 主题内容 -->
	<view  class="padding-t">
		<view class="public-main-info">
			<view class="u-main">
				<!-- 内容区域 -->
				<view class="padding2030">
					<!-- 头部 -->
					<view class="flex dashed-top list-height u-font-weight" style="background: rgba(48,136,244,0.10);">
						<view class="basis-sm">指标名称</view>
						<view class="basis-sm">不合格数</view>
						<view class="basis-xs">合格率</view>
						<view></view>
					</view>
					<view class="">
						<view class="flex dashed-top list-height u-font-weight" v-for="(item, index) in list" :key="index">
							<view class="basis-sm">{{item.name}}</view>
							<view class="basis-sm">{{item.unqualifiedNumber}}</view>
							<view class="basis-xs">{{item.passRate}}</view>
							<view></view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	<view class="cu-tabbar-height"></view>
</view>
</template>

<script>
import { post, getTime } from "@/lib/Util.js";
import {GET_QUALITY_INFO_STATISTICS } from '@/common/api/quality.js'
export default {
	data() {
		return {
			date: '',
			list: [
				{
					name: '---',
					unqualifiedNumber: '---',
					passRate: '---'
				}
			]
		}
	},
	mounted() {
		this.date = getTime()
		this.getInfo()
	},
	methods: {
		beforePage() {
			uni.navigateBack({
				delta: 1
			});
		},
		DateChange(e) {
			this.date = e.detail.value
			this.getInfo(this.date)
		},
		handleTabClick(e) {
			this.flagIndex = e.target.id
		},
		async getInfo() {
			let res = await post(GET_QUALITY_INFO_STATISTICS, {time: this.date})
			if(res.code == 0) {
				this.list = res.data
			}
		}
	}
}
</script>

<style>

</style>
